package io.renren.modules.shop.controller;

import java.util.Arrays;
import java.util.Map;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import io.renren.modules.shop.entity.ShopEntity;
import io.renren.modules.shop.service.ShopService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * 
 *
 * @author LL
 * @email wdlyl@163.com
 * @date 2022-04-12 14:48:24
 */
@Api(value = "商家相关", tags = { "商家相关" })
@RestController
@RequestMapping("shop")
public class ShopController {
    @Autowired
    private ShopService shopService;

    /**
     * 列表
     */
    @ApiOperation("查询商家列表")
    @GetMapping("/list")
    //@RequiresPermissions("car:store:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = shopService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @ApiOperation("单条商家信息")
    @GetMapping("/info/{storeId}")
    //@RequiresPermissions("car:store:info")
    public R info(@ApiParam("商家id") @PathVariable("storeId") String storeId){
		ShopEntity store = shopService.getById(storeId);

        return R.ok().put("store", store);
    }

    /**
     * 保存
     */
    @PostMapping("/save")
    //@RequiresPermissions("car:store:save")
    public R save(@RequestBody ShopEntity store){
		shopService.save(store);

        return R.ok();
    }

    /**
     * 修改
     */
    @PostMapping("/update")
    //@RequiresPermissions("car:store:update")
    public R update(@RequestBody ShopEntity store){
		shopService.updateById(store);

        return R.ok();
    }

    /**
     * 删除
     */
    @PostMapping("/delete")
    //@RequiresPermissions("car:store:delete")
    public R delete(@RequestBody String[] storeIds){
		shopService.removeByIds(Arrays.asList(storeIds));

        return R.ok();
    }

}
